package com.lxg.service.firstService.impl;

import com.lxg.dao.UserDao;
import com.lxg.pojo.User;
import com.lxg.service.firstService.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RegisterServiceImpl implements RegisterService {
    @Autowired
    UserDao userDao;

    /**
     * 判断用户名是否被占用
     * @param username
     * @return
     */
    @Override
    public User getUserByUsername(String username) {
        User user = userDao.checkUsername(username);
        return user;
    }


    /**
     * 判断邮箱是否被占用
     * @param email
     * @return
     */
    @Override
    public User getUserByEmail(String email) {
        User user = userDao.checkEmail(email);
        return user;
    }

    @Override
    public User getUserByPhone(String phone) {
        User user = userDao.checkPhone(phone);
        return user;
    }


    /**
     * 读者进行注册
     * @param username
     * @param name
     * @param password
     * @param email
     * @param phone
     * @return
     */
    @Override
    public boolean ReaderRegister(String username, String password, String name,
                                  String sno, String grade, String email, String phone) {
        userDao.addUser(username, password, name, sno, grade, email, phone);
        return true;
    }

    @Override
    public User getUserBySno(String sno) {
        User user = userDao.checkSno(sno);
        return user;
    }
}
